home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c
- Subject: Re: Basic Question on SWITCH
- Date: Thu, 01 Feb 1996 03:48:41 GMT
- Organization: Netcom
- Message-ID: <31103648.28902464@nntp.ix.netcom.com>
- References: <4e4cu4$95f@vixen.cso.uiuc.edu> <4e8p6m$n8q@ns.RezoNet.NET> <TANMOY.96Jan26162346@qcd.lanl.gov> <4ehfuj$166g@ns.RezoNet.NET>
- NNTP-Posting-Host: ix-dc11-20.ix.netcom.com
- X-NETCOM-Date: Wed Jan 31 7:49:12 PM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- ray@ultimate-tech.com (Ray Dunn) wrote:
-
- > In referenced article, Tanmoy Bhattacharya says...
- > >
- > >In article <3108ED49.987@cmt.lpr.mail.carel.fi> Ari Lukumies
- > ><aril@cmt.lpr.mail.carel.fi> writes:
- > ><snip>
- > > if (strchr("0123456789", a))
- > > ... /* It was a digit, do something */
- > >
- > >A special case for digits:
- > >
- > >if ((unsigned)(a-'0')<10)
- > > /* It _is_ a digit, do something */
- > >
- > >But then what is wrong with isdigit?
- >
- > Indeed. In the general case there is no guarantee that all the digits
- > are consecutive as they are in ASCII, so the use of isdigit is the only
- > portable way to go, although the strchr example works fine too, if
- > slowly.
- >
- > [As a matter of interest, MS 'C' uses a character table with bits
- > defining all the various character types. isdigit etc. uses this
- > table. MS provides profiling functions which allows the customization
- > of this table]
-
- But one needn't worry about the general case. This is comp.lang.c and
- in C the digits must be consecutive with '0' the smallest. From ISO
- 5.2.1:
-
- In both the source and execution basic character sets, the
- value of each character after 0 in the above list of decimal
- digits shall be one grater than the value of the previous.
-
-
- Michael M Rubenstein
-